package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.FlightOrderCabinrule;
import com.ktgj.flight.service.IFlightOrderCabinruleService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 每个订单的退改签信息Controller
 * 
 * @author ruoyi
 * @date 2021-10-26
 */
@ControllerAdvice
@RestController
@RequestMapping("/cabinrules")
public class FlightOrderCabinruleController extends BaseController
{
    @Autowired
    private IFlightOrderCabinruleService flightOrderCabinruleService;

    /**
     * 查询每个订单的退改签信息列表
     */
    @PreAuthorize(hasPermi = "flight:cabinrule:list")
    @GetMapping("/list")
    public TableDataInfo list(FlightOrderCabinrule flightOrderCabinrule)
    {
        startPage();
        List<FlightOrderCabinrule> list = flightOrderCabinruleService.selectFlightOrderCabinruleList(flightOrderCabinrule);
        return getDataTable(list);
    }

    /**
     * 导出每个订单的退改签信息列表
     */
    @PreAuthorize(hasPermi = "flight:cabinrule:export")
    @Log(title = "每个订单的退改签信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlightOrderCabinrule flightOrderCabinrule) throws IOException
    {
        List<FlightOrderCabinrule> list = flightOrderCabinruleService.selectFlightOrderCabinruleList(flightOrderCabinrule);
        ExcelUtil<FlightOrderCabinrule> util = new ExcelUtil<FlightOrderCabinrule>(FlightOrderCabinrule.class);
        util.exportExcel(response, list, "每个订单的退改签信息数据");
    }

    /**
     * 获取每个订单的退改签信息详细信息
     */
    @PreAuthorize(hasPermi = "flight:cabinrule:query")
    @GetMapping(value = "/{orderCabinruleId}")
    public AjaxResult getInfo(@PathVariable("orderCabinruleId") Long orderCabinruleId)
    {
        return AjaxResult.success(flightOrderCabinruleService.selectFlightOrderCabinruleById(orderCabinruleId));
    }

    /**
     * 新增每个订单的退改签信息
     */
    @PreAuthorize(hasPermi = "flight:cabinrule:add")
    @Log(title = "每个订单的退改签信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlightOrderCabinrule flightOrderCabinrule)
    {
        return toAjax(flightOrderCabinruleService.insertFlightOrderCabinrule(flightOrderCabinrule));
    }

    /**
     * 修改每个订单的退改签信息
     */
    @PreAuthorize(hasPermi = "flight:cabinrule:edit")
    @Log(title = "每个订单的退改签信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlightOrderCabinrule flightOrderCabinrule)
    {
        return toAjax(flightOrderCabinruleService.updateFlightOrderCabinrule(flightOrderCabinrule));
    }

    /**
     * 删除每个订单的退改签信息
     */
    @PreAuthorize(hasPermi = "flight:cabinrule:remove")
    @Log(title = "每个订单的退改签信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderCabinruleIds}")
    public AjaxResult remove(@PathVariable Long[] orderCabinruleIds)
    {
        return toAjax(flightOrderCabinruleService.deleteFlightOrderCabinruleByIds(orderCabinruleIds));
    }
}
